package Practice08.test2;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TestEmployee {
    public static void main(String[] args) {
        int sum = 0;

        List<Employee> employees = new ArrayList<>();
        employees.add(new Employee(1001,"Tom","Market",1200));
        employees.add(new Employee(1002,"Jack","Department",1300));
        employees.add(new Employee(1003,"Simth","Market",2200));
        employees.add(new Employee(1004,"Tony","Department",3000));

        for (Employee e: employees) {

            sum += e.getSalary();
            System.out.println(e.getName());
            System.out.println(e.getName()+e.getSalary());

            if (e.getName().equals("Jack")){
                System.out.println(e);
                e.changePay(1500);
            }

            if (e.getSalary() < 1000){
                e.changePay(0.2);
            }
        }
        System.out.println("总工资："+sum);

        Iterator<Employee> iterator = employees.iterator();
        while (iterator.hasNext()){
            Employee emp = iterator.next();
            if (emp.getName().equals("Tom")){
                iterator.remove();
            }
        }
        System.out.println(employees);
    }
}
